package com.example.testeviews;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.widget.Chronometer;
import android.widget.Chronometer.OnChronometerTickListener;

public class ClockActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.clock);
		
		Chronometer chrono = (Chronometer) findViewById(R.id.chronometer1);
		chrono.setBase(SystemClock.elapsedRealtime());
		
		chrono.setOnChronometerTickListener(new OnChronometerTickListener() {
			
			@Override
			public void onChronometerTick(Chronometer chronometer) {
				long elapsedTime = SystemClock.elapsedRealtime() - chronometer.getBase();
				Log.i(this.getClass().getName(), "" + elapsedTime);
				if (elapsedTime > 10000) {
					chronometer.stop();
				}
			}
		});
		chrono.start();
	}
}
